package wiki.so.api;

/**
 * An interface for storing and accessing Stack-Overflow like content, including operations
 * to synchronize the local storage with the Stack-Overflow website.
 *
 */
public interface IStackOverflowWiki {
	/**
	 * Container for holding information for a forum (question and all answers
	 * to it).
	 *
	 */
	static class Forum {
		public StackOverflowQuestion	question;
		public StackOverflowAnswer		answers[];
	}
	
	/**
	 * Add a new question to the wiki.
	 * @param q		The question to be added.
	 */
	void addQuestion(StackOverflowQuestion q);
	
	/**
	 * Modify an existing question in the wiki.
	 * @param q		The question to be modified, after modifications have been performed.
	 */
	void modifyQuestion(StackOverflowQuestion q);
	
	/**
	 * Delete a question from the wiki, including all answers to that question.
	 * @param q		The question to delete.
	 */
	void deleteQuestion(StackOverflowQuestion q);
	
	/**
	 * Add a new answer to the wiki.
	 * @param q		The question the new answer is answering.
	 * @param a		The new answer.
	 */
	void addAnswer(StackOverflowQuestion q, StackOverflowAnswer a);
	
	/**
	 * Modify an existing answer in the wiki.
	 * @param a		The answer to be modified, after modifications have been performed.
	 */
	void modifyAnswer(StackOverflowAnswer a);
	
	/**
	 * Delete an answer from the wiki.
	 * @param a		The answer to delete.
	 */
	void deleteAnswer(StackOverflowAnswer a);
	
	/**
	 * Retrieves a question or answer with the specified name. The name is the one returned
	 * by calling the object's {@link il.ac.technion.wiki.api.Content#getContentName getContentName} method.
	 * @param name	The name of the question/answer to retrieve.
	 * @return		The retrieved question/answer, or <tt>null</tt> if no content with the specified name
	 * 				exists.
	 */
	StackOverflowContent get(String name);
	
	/**
	 * Retrieve the question associated with a particular answer.
	 * @param a		The answer to retrieve the question for.
	 * @return		The question being answered by <tt>a</tt>.
	 */
	StackOverflowQuestion getQuestion(StackOverflowAnswer a);
	
	/**
	 * Retrieve the answers associated with a particular question.
	 * @param q		The question to retrieve answers for.
	 * @return		An array of all answers to <tt>q</tt>.
	 */
	StackOverflowAnswer[] getAnswers(StackOverflowQuestion q);
	
	/**
	 * Retrieves the full forum (question + all answers to it) for a specified question or answer.
	 * @param c		The question/answer to retrieve forum for.
	 * @return		The resulting forum.
	 */
	Forum getForum(StackOverflowContent c);
}
